package ds.dsr.controller;

import ds.dsr.enums.RetTipEnum;
import ds.dsr.model.RetJson;
import ds.dsr.server.model.ServiceInfo;
import ds.dsr.server.params.ServerContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @author sunchong
 * @date 2018/4/25
 */
@RestController
public class ServerInfoController {

    @GetMapping("/online")
    public RetJson<AtomicLong> onlineNum(){
        RetJson retJson = new RetJson();
        retJson.setTip(RetTipEnum.SUCCESS);
        retJson.setData(ServerContext.onlineNum);
        return retJson;
    }

    @GetMapping("service/info")
    public RetJson<Map<String, ServiceInfo>> serviceAppInfo(){
        RetJson retJson = new RetJson();
        retJson.success(ServerContext.serviceInfoTable);
        return retJson;
    }

}
